$(function () {
    setInterval(function () {
        $.get($.webPath() + "/portal/keepAlive", function (data) {
            $("#onlineCount").text(data);
        });
    }, 5 * 60 * 1000);

    $.get($.webPath() + "/portal/keepAlive", function (data) {
        if ($("#onlineCount").length) {
            onlineCount(data);
        }
    });
});

function onlineCount(data) {
    if ($("#onlineCount").length) {
        $("#onlineCount").text(data);
    } else {
        setTimeout("onlineCount(" + +")", 100);
    }
}